<template>
	<view></view>
</template>

<script>
export default {
	name: 'customerOperate',
	props: {
		value: {
			type: String,
			default: ''
		},
		oper_item: {
			type: Object,
			default: {}
		}
	},
	data() {
		return {};
	},
	watch: {
		value(val) {
			let that = this;
			switch (val) {
				case 'user_editMsg':
					uni.navigateTo({
						url: '/pagesC/customerManagement/addCustomer/addCustomer?id=' + that.oper_item.id
					});
					break;
				case 'user_del':
					uni.showModal({
						title: '提示',
						content: `确认删除“${that.oper_item.name}”吗?`,
						showCancel: true,
						success(res) {
							if (res.confirm) {
								uni.showLoading({
									mask: true
								});
								that.$Apipc
									.delUser({
										id_arr: [that.oper_item.id]
									})
									.then((res) => {
										console.log(res, '删除用户');
										uni.hideLoading();
										if (res.code == 200) {
											that.$emit('submit', that.oper_item.id);
										}
										uni.showToast({
											title: res.message,
											icon: res.code == 200 ? 'success' : 'error'
										});
									});
							}
						}
					});
					break;

				default:
			}
			this.close();
		}
	},
	methods: {
		close(type) {
			this.$emit('update:value', '');
		}
	}
};
</script>

<style lang="scss"></style>
